package com.bwie.controller;


import com.bwie.login.AdminLoginVo;
import com.bwie.pojo.TbUser;
import com.bwie.service.impl.TbUserServiceImpl;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: zhaijiaqi
 * @Date: 2025/4/21 16:13
 * @Description:
 **/
@RestController
@RequestMapping("/user/index")
@RefreshScope
public class IndexController {

    @Autowired
    TbUserServiceImpl tbUserService;

//    @Autowired
//    NocosConfig nocosConfig;
    @Value("${server.port}")
    private Integer serverPort;

//    @Value("${site.ip}")
//    private String ip;

    /**
     * 根据ID获取用户信息
     * @param userId
     * @return
     */
    @PostMapping("/getUserByid/{userId}")
    public R getUserByid(@PathVariable("userId") Integer userId){
        System.out.println("serverPort:"+serverPort);
        return tbUserService.getuserByid(userId);
    }

//    @PostMapping("/getConfig")
//    public R getConfig(){
//        System.out.println("className"+nocosConfig.getClassName());
//        return R.OK(nocosConfig.getClassName());
//    }

//    @PostMapping("/getNacosIp")
//    public R getNacosIp(){
//        System.out.println("ip"+ip);
//        return R.OK("Ip"+ip);
//    }

    /**
     * 登录管理
     * @return
     */
    @PostMapping("/AdminLogin")
    public R AdminLogin(@RequestBody AdminLoginVo adminLoginVo){
      return   tbUserService.AdminLogin(adminLoginVo);
    }

    /**
     * 用户列表
     * @return
     */
    @PostMapping("/getUserList")
    public R userList(@RequestBody PageInfoVo pageInfoVo){

        return tbUserService.UserList(pageInfoVo);
    }

    /**
     * 用户注册
     * @return
     */
    @PostMapping("/UserReg")
    public R UserReg(@RequestBody @Validated TbUser tbUser){
        return tbUserService.UserRge(tbUser);
    }

    /**
     * 审核状态
     * @return
     */
    @PostMapping("/checkStatus")
    public R checkStatus(@RequestBody TbUser tbUser){
        return tbUserService.checkStatus(tbUser);
    }

    /**
     * 获取个人信息
     * @return
     */
    @PostMapping("/GetMyinfo")
    public R GetMyinfo(){
        return tbUserService.GetMyinfo();
    }

    /**
     * 修改信息
     * @return
     */
    @PostMapping("/updataUser")
    public R updataUser(@RequestBody @Validated TbUser tbUser ){
      return   tbUserService.updataUser(tbUser);
    }


}
